package com.elinkway.infinitemovies.async;

import android.content.Context;

import com.elinkway.infinitemovies.bean.UTPState;
import com.elinkway.infinitemovies.http.api.MoviesHttpApi;
import com.elinkway.infinitemovies.http.parser.UTPLiveParser;
import com.lvideo.http.bean.LVideoDataHull;

public class RequestUtpStateTask extends MoviesHttpAsyncTask<UTPState> {

    private RequestResultListener<UTPState> mListener;

    public RequestUtpStateTask(Context context) {
        super(context);
    }

    @Override
    public LVideoDataHull<UTPState> doInBackground() {
        return MoviesHttpApi.requestUtpLiveServer(new UTPLiveParser());
    }

    @Override
    public void netNull() {
        super.netNull();
        if (null != mListener) {
            mListener.onRequestSuccess(-1, null);;
        }
    }

    @Override
    public void netErr(int updateId, String errMsg) {
        super.netErr(updateId, errMsg);
        if (null != mListener) {
            mListener.onRequestSuccess(updateId, null);;
        }
    }

    @Override
    public void onPostExecute(int updateId, UTPState result) {
        if (null != mListener) {
            mListener.onRequestSuccess(updateId, result);;
        }
    }

    @Override
    public void preFail() {
        super.preFail();
        if (null != mListener) {
            mListener.onRequestSuccess(-1, null);;
        }
    }

    public RequestResultListener<UTPState> getmListener() {
        return mListener;
    }

    public void setmListener(RequestResultListener<UTPState> mListener) {
        this.mListener = mListener;
    }

}
